package com.wanmait.schedule.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * <p>
 * 项目表
 * </p>
 *
 * @author wanmait
 * @since 2022-03-02
 */
@Data
@Document(indexName = "project")
@Accessors(chain = true)
@Setting(shards = 5,replicas = 1)//分片
public class Project {

    @TableId(value = "id", type = IdType.AUTO)
    @Id
    @Field(type = FieldType.Keyword)
    private Integer id;

    /**
     * 名称
     */
    @TableField(condition = SqlCondition.LIKE)
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String name;

    /**
     * 详情
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String details;

    /**
     * 部门id
     */
    @Field(name = "department_id",type = FieldType.Integer)
    private Integer departmentId;

    @TableField(exist = false)
    private  Department department;

    /**
     * 企业id
     */
    @Field(name = "company_id",type = FieldType.Integer)
    private Integer companyId;

    @TableField(exist = false)
    private Company company;

    /**
     * 发布时间
     */
    @Field(name = "pub_time",type = FieldType.Date,format = DateFormat.date_optional_time)
    private Date pubTime;

    /**
     * 开始时间(企业指定)
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field(name = "start_time",type = FieldType.Date,format = DateFormat.date_optional_time)
    private Date startTime;

    /**
     * 预计结束时间（企业指定）
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field(name = "est_time",type = FieldType.Date,format = DateFormat.date_optional_time)
    private Date estTime;

    /**
     * 结束时间（部门最终提交时间）
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Field(name = "end_time",type = FieldType.Date,format = DateFormat.date_optional_time)
    private Date endTime;

    /**
     * 接受项目人id
     */
    @Field(name = "company_user_id",type = FieldType.Integer)
    private Integer companyUserId;

    @TableField(exist = false)
    private CompanyUser companyUser;

    /**
     * 部长是否提交项目（1为提交，默认为0）
     */
    @TableField
    @Field(type = FieldType.Boolean)
    private Boolean submit;

    /**
     * 老板审核该项目是否完成（0为通过，1为未通过，默认为1）
     */
    @TableLogic
    @Field(type = FieldType.Boolean)
    private Boolean ispass;
    /**
     * 此项目底下 的所有任务
    * */
    @TableField(exist = false)
    private List<Task> taskList;


}
